<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/3/14
 * Time: 17:36
 */

namespace Home\Controller;


use Think\Controller;

class TeamController extends Controller
{
    public function index(){
        if(IS_POST){
            $Team = D('Team');
            $data = $Team->create();
            if($data){
                $corpsname  = explode(",",$_POST['corpsname']);
                $Team->corpsnumbers = $corpsname[0];
                $Team->name = $corpsname[1];
                if($Team->add()){
                    $this->success("成功");
                }
                else{
                    $this->error("失败");
                }
            }
        }
        $match =  D('Match')->order("created_at desc")->select();

        $corps = D('Corps')->where("status=1")->field("corpsnumber,corpsname")->select();
        $this->assign("corps",$corps);
        $this->assign("match",$match);
        $this->display();
    }

}